.TH std::codecvt::unshift,do_unshift 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::codecvt::unshift,do_unshift \- std::codecvt::unshift,do_unshift

.SH Synopsis
   Defined in header <locale>
   public:

   result unshift( StateT& state, ExternT* to, ExternT* to_end,            \fB(1)\fP

                   ExternT*& to_next ) const;
   protected:

   virtual result do_unshift( StateT& state, ExternT* to, ExternT* to_end, \fB(2)\fP

                              ExternT*& to_next ) const;

   1) Public member function, calls the member function do_unshift of the most derived
   class.
   2) If the encoding represented by this codecvt facet is state-dependent, and state
   represents a conversion state that is not the initial shift state, writes the
   characters necessary to return to the initial shift state. The characters are
   written to a character array whose first element is pointed to by to. No more than
   to_end - to characters are written. The parameter to_next is updated to point one
   past the last character written.

.SH Return value

   A value of type std::codecvt_base::result, indicating the success status as follows:

   ok      all necessary characters were written. state now represents initial shift
           state
   partial not enough space in the output buffer. to_next == to_end
   error   an unspecified error has occurred
   noconv  the encoding is not state-dependent, no termination sequence necessary

.SH Notes

   This function is called by std::basic_filebuf::close() and in other situations when
   finalizing a state-dependent multibyte character sequence.

.SH Example

    This section is incomplete
    Reason: no example

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

     DR    Applied to            Behavior as published               Correct behavior
                      std::codecvt<wchar_t, char,
   LWG 305 C++98      std::mbstate_t>::do_unshift                  not required
                      was required not to write any character
                      the meaning of returning partial was 'more   corrected to
   LWG 380 C++98      characters need to                           indicating
                      be supplied to complete termination', but no insufficient buffer
                      character is supplied                        space
                                                                   state is required to
   LWG 381 C++98      state was not required to be valid, and      be valid, and
                      error is returned if state is invalid        returning error
                                                                   indicates an error
                      std::codecvt<char, char,
   LWG 664 C++98      std::mbstate_t>::do_unshift                  not required
                      was required not to write any character
                      std::codecvt<char, char,
   LWG 665 C++98      std::mbstate_t>::do_unshift                  not required
                      was required to return noconv

.SH See also

   wcrtomb   converts a wide character to its multibyte representation, given state
             \fI(function)\fP
   do_out    converts a string from InternT to ExternT, such as when writing to file
   \fB[virtual]\fP \fI(virtual protected member function)\fP

.SH Category:
     * Todo no example
